package beans;

import db.Entity;

import java.sql.Timestamp;

public class User extends Entity {

    public final static int MAX_ACCOUNT_LENGTH = 24; //限制账号最大长度
    public final static int MIN_ACCOUNT_LENGTH = 4; //限制账号最小长度
    public final static int MAX_PWD_LENGTH = 16; //限制密码最大长度
    public final static int MIN_PWD_LENGTH = 6; //限制密码最小长度

    public static boolean isAccountAndPwdLengthLegal(String account, String pwd) {
        if (account == null || pwd == null) return false;
        int accountLength = account.getBytes().length;
        int pwdLength = pwd.getBytes().length;
        return accountLength <= MAX_ACCOUNT_LENGTH && accountLength >= MIN_ACCOUNT_LENGTH
                && pwdLength <= MAX_PWD_LENGTH && pwdLength >= MIN_PWD_LENGTH;
    }

    @Override
    public String tableName() {
        return "wb_user";
    }

    private long id;
    private String account;
    private String pwd;
    private Timestamp create_time;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public Timestamp getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Timestamp create_time) {
        this.create_time = create_time;
    }

}
